﻿CREATE PROCEDURE [dbo].[proc_Order_Getlist_my_Count]
	(
		@UserName nvarchar(50),
		@StateId int,
		@TypeId int,
		@WayId int,
		@ProcessId int,
		@Stext nvarchar(50),
		@StartDate nvarchar(10),
		@EndDate nvarchar(10)
	)
AS
begin
	Select Count(Id) From [Order]
	Where SalesmanAccount=@UserName
		and (@StateId=0 Or StateId=@StateId) and (@TypeId=0 Or TypeId=@TypeId) and (@WayId=0 Or WayId=@WayId) and (@ProcessId=0 Or ProcessId=@ProcessId)
		and (Convert(nchar(10),TradeDate,120) between @StartDate and @EndDate)
		and (@Stext='' Or CusName like '%'+@Stext+'%')
end
	RETURN
